<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">新增</ui:define>
    <ui:define name="content">
        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar >
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         actionListener="#{settlementPriceInfoBean.onFind}" update="@form" process="@this,companyId"
                                         rendered="#{settlementPriceInfoBean.isAdd()}"/>
                        <p:commandButton id="save" value="保存" icon="fa fa-save"
                                         actionListener="#{settlementPriceInfoBean.onSave}"
                                         rendered="#{settlementPriceInfoBean.isAdd() and settlementPriceInfoBean.$.companyId!=null}"
                                         update="@form"/>
                        <!--<p:commandButton value="取消" icon="fa fa-reply" rendered="#{settlementPriceInfoBean.isAdd()}"/>-->
                        <p:button value="返回" icon="fa fa-reply-all" href="#{currentUserBean.back}"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-g ui-fluid" style="padding-top: 30px;">
                <div class="ui-g-12 ">
                    <div class="ui-g-12 card">
                        <h1>请筛选结算日期以及输入公司名称后点击查询</h1>
                        <div class="ui-g-1">
                            <p:outputLabel value="公司名称"/>
                            <strong style="color: red">*</strong>
                        </div>
                        <div class="ui-g-3">
                            <p:selectOneMenu id="companyId" value="#{settlementPriceInfoBean.$.companyId}" filter="true"
                                             filterMatchMode="contains">
                                <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                <f:selectItems value="#{settlementPriceInfoBean.companyInfoList}"
                                               var="company"
                                               itemLabel="#{company.companyName}" itemValue="#{company.id}"/>
                            </p:selectOneMenu>
                        </div>
                    </div>
                </div>
                <div class="ui-g-12">
                    <div class="ui-g-12 card">
                        <h1>价格变更</h1>

                        <p:outputPanel id="perPrice">
                            <p:outputPanel rendered="#{settlementPriceInfoBean.$.copMode != null}">
                                <div class="ui-g-2">
                                    <p:outputLabel value="新合作模式"/>
                                    <strong style="color: red">*</strong>
                                </div>
                                <div class="ui-g-4">

                                    <p:selectOneMenu  value="#{settlementPriceInfoBean.$.newCopMode}" disabled="#{settlementPriceInfoBean.isView()}">
                                        <p:ajax event="change" listener="#{settlementPriceInfoBean.onChangeCopMode}" process="@this"
                                                update="perPrice" />
                                        <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                                      noSelectionOption="true"/>
                                        <f:selectItems
                                                value="#{settlementPriceInfoBean.dictionaries[DictionaryCode.COOPERATION_MODE]}"
                                                var="dic"
                                                itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                    </p:selectOneMenu>

                                </div>

                                <div class="ui-g-2">
                                    <p:outputLabel value="旧合作模式"/>
                                    <strong style="color: red">*</strong>
                                </div>
                                <div class="ui-g-4">
                                    <p:selectOneMenu  value="#{settlementPriceInfoBean.$.copMode}" disabled="true">
                                        <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                                      noSelectionOption="true"/>
                                        <f:selectItems
                                                value="#{settlementPriceInfoBean.dictionaries[DictionaryCode.COOPERATION_MODE]}"
                                                var="dic"
                                                itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                    </p:selectOneMenu>
                                </div>
                            </p:outputPanel>
                            <p:outputPanel rendered="#{settlementPriceInfoBean.$.newCopMode==null?
                            (settlementPriceInfoBean.$.copMode==1 or settlementPriceInfoBean.$.copMode==3):
                            (settlementPriceInfoBean.$.newCopMode==1 or settlementPriceInfoBean.$.newCopMode==3)}">
                                <div class="ui-g-2">
                                    <p:outputLabel value="新结算价格"/>
                                    <strong style="color: red">*</strong>
                                </div>
                                <div class="ui-g-4">
                                    <div class="input-group">
                                        <p:inputText type="number" value="#{settlementPriceInfoBean.$.newPercentPrice}"
                                                     disabled="#{settlementPriceInfoBean.isView()}"/>
                                        <span class="input-group-addon">%</span>
                                    </div>
                                </div>
                                <div class="ui-g-2">
                                    <p:outputLabel value="旧结算价格"/>
                                </div>
                                <div class="ui-g-4">
                                    <div class="input-group">
                                        <p:inputText type="number"
                                                     value="#{settlementPriceInfoBean.$.oldPercentPrice}"
                                                     disabled="true"/>
                                        <span class="input-group-addon">%</span>
                                    </div>
                                </div>
                            </p:outputPanel>
                            <p:outputPanel
                                    rendered="#{settlementPriceInfoBean.$.newCopMode==null?
                                    (settlementPriceInfoBean.$.copMode==0 or settlementPriceInfoBean.$.copMode==2 or settlementPriceInfoBean.$.copMode==3):
                                     (settlementPriceInfoBean.$.newCopMode==0 or settlementPriceInfoBean.$.newCopMode==2 or settlementPriceInfoBean.$.newCopMode==3)}">
                                <div class="ui-g-2">
                                    <p:outputLabel value="新结算价格"/>
                                    <strong style="color: red">*</strong>
                                </div>
                                <div class="ui-g-4">
                                    <div class="input-group">
                                        <p:inputNumber value="#{settlementPriceInfoBean.$.newYuanPrice}"
                                                       disabled="#{settlementPriceInfoBean.isView()}"/>
                                        <span class="input-group-addon">元</span>
                                    </div>
                                </div>
                                <div class="ui-g-2">
                                    <p:outputLabel value="旧结算价格"/>
                                </div>
                                <div class="ui-g-4">
                                    <div class="input-group">
                                        <p:inputNumber value="#{settlementPriceInfoBean.$.oldYuanPrice}"
                                                       disabled="true"/>
                                        <span class="input-group-addon">元</span>
                                    </div>
                                </div>
                            </p:outputPanel>
                        </p:outputPanel>
                        <div class="ui-g-2">
                            <p:outputLabel value="开始生效日期"/>
                            <strong style="color: red">*</strong>
                        </div>
                        <div class="ui-g-4">
                            <p:calendar value="#{settlementPriceInfoBean.$.effectiveTime}"
                                        id="recordStartTime"
                                        locale="#{constants:get('LOCALE')}"
                                        timeZone="#{constants:get('TIME_ZONE')}"
                                        pattern="#{constants:get('DATE_FORMAT')}"
                                        disabled="#{settlementPriceInfoBean.isView()}"/>
                        </div>
                        <div class="ui-g-2">
                            <p:outputLabel value="变更人"/>
                        </div>
                        <div class="ui-g-4">
                            <p:inputText value="#{settlementPriceInfoBean.$.updator}"
                                         disabled="true"/>
                        </div>
                        <div class="ui-g-2">
                            <p:outputLabel value="变更时间"/>
                        </div>
                        <div class="ui-g-4">
                            <p:inputText value="#{settlementPriceInfoBean.$.updateTime}"   disabled="true">
                                <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                            </p:inputText>
                        </div>
                    </div>

                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
